<?php

namespace app\admin\model\photo;

use think\Model;


class Itinerary extends Model
{

    

    

    // 表名
    protected $name = 'photo_itinerary';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text'
    ]; 
    

    
    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1')];
    }
    public function getStatusAttr($value)
    {
        $status = [1=>'已启用', 0=>'未启用'];
        return $status[$value];
    }
    public function getStatusTextAttr($value,$data)
    {
        $status = [1=>'不可删除', 0=>'可删除'];
        return $status[$data['status']];
    }
     public function route()
    {
         
         return $this->hasOne('Route', 'id', 'route_id');
         
    }
      public function user()
    {
         
         return $this->hasOne(\app\admin\model\User::class, 'id', 'account_id');
         
    }
    public function related()
    {
         
         return $this->belongsTo('Related', 'id', 'itinerary_id');
         
    }
  


    // public function getStatusTextAttr($value, $data)
    // {
    //     $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
    //     $list = $this->getStatusList();
    //     return isset($list[$value]) ? $list[$value] : '';
    // }




}
